class TestException:

    def exp(self):
        f = "123"
        try:
            f = open("help.txt","r")
            f.read(5)
        except FileNotFoundError:
            print("文件不存在")
        finally:
            print("关闭文件")
            f.close()

    def handle_exp():
        a = 0
        try:
            print 20/a
        except ArithmeticError, e:
            print "发生错误了"
            print e
            raise ArithmeticError()    # 抛出异常
        else:
            print "没有发生异常"

        # 你可以使用except语句或者finally语句，但是两者不能同时使用。
        try:
            print 2*a
        finally:
            print "无论时否异常均处理"
        # raise

if __name__ == '__main__':
    test = TestException()
    test.exp()